package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointMerchantMarketing;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 가맹점 마케팅 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointMerchantMarketingDaoImpl extends SqlSessionDaoSupport implements CarrotPointMerchantMarketingDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointMerchantMarketingDaoImpl.class);

    /**
     * 가맹점 마케팅을 등록 한다.
     *
     * @param carrotPointMerchantMarketing
     */
    @Override
    public void registerMerchantMarketing(CarrotPointMerchantMarketing carrotPointMerchantMarketing) {
        logger.info("registerMerchantMarketing");
        this.getSqlSession().insert("CARROTPOINT_MERCHANT_MARKETING.registerMerchantMarketing", carrotPointMerchantMarketing);
    }

    /**
     * 가맹점 마케팅 목록을 가져 온다.
     *
     * @param carrotPointMerchantMarketing
     * @return
     */
    @Override
    public List<CarrotPointMerchantMarketing> getMerchantMarketingList(CarrotPointMerchantMarketing carrotPointMerchantMarketing) {
        logger.info("getMerchantMarketingList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_MARKETING.getMerchantMarketingList", carrotPointMerchantMarketing);
    }

    /**
     * 가맹점 마케팅 내용을 가져 온다.
     *
     * @param carrotPointMerchantMarketing
     * @return
     */
    @Override
    public CarrotPointMerchantMarketing getMerchantMarketingInformation(CarrotPointMerchantMarketing carrotPointMerchantMarketing) {
        logger.info("getMerchantMarketingInformation");
        return (CarrotPointMerchantMarketing)getSqlSession().selectOne("CARROTPOINT_MERCHANT_MARKETING.getMerchantMarketingInformation", carrotPointMerchantMarketing);
    }

    /**
     * 가맹점 마케팅 내용을 수정 한다.
     *
     * @param carrotPointMerchantMarketing
     */
    @Override
    public void updateMerchantMarketingInformation(CarrotPointMerchantMarketing carrotPointMerchantMarketing) {
        logger.info("updateMerchantMarketingInformation");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_MARKETING.updateMerchantMarketingInformation", carrotPointMerchantMarketing);
    }

    /**
     * 가맹점 마케팅을 비활성화 한다.
     *
     * @param carrotPointMerchantMarketing
     */
    @Override
    public void updateDeactivateMerchantMarketing(CarrotPointMerchantMarketing carrotPointMerchantMarketing) {
        logger.info("updateDeactivateMerchantMarketing");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_MARKETING.updateDeactivateMerchantMarketing", carrotPointMerchantMarketing);
    }
}
